package cn.stylefeng.guns.modular.controller;

import cn.stylefeng.guns.core.pojo.response.ResponseData;
import cn.stylefeng.guns.core.pojo.response.SuccessResponseData;
import cn.stylefeng.guns.modular.param.ReservedAddParam;
import cn.stylefeng.guns.modular.service.ReservedService;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

/**
 * @author 李宝嘉
 * @Date 2022/1/4 14:37
 */
@RestController
@RequestMapping("/reserved")
public class ReservedController {
    @Resource
    public ReservedService reservedService;

    @PostMapping("/add")
    public ResponseData addReserved(@RequestBody ReservedAddParam reservedAddParam) {
        reservedService.addReserved(reservedAddParam);
        return new SuccessResponseData();

    }

    @GetMapping("/list/by/user")
    public ResponseData listByUser() {
        return new SuccessResponseData(reservedService.getListByUser());
    }

    @GetMapping("/signin")
    public ResponseData seatSignIn(@RequestParam Long seatId, @RequestParam Long reservedId) {
        reservedService.seatSignIn(seatId, reservedId);
        return new SuccessResponseData();
    }

    @GetMapping("/cancel")
    public ResponseData cancelReserved(@RequestParam Long reservedId) {
        reservedService.cancelReserved(reservedId);
        return new SuccessResponseData();
    }

    @RequestMapping("/withdraw")
    public ResponseData withdrawReserved(@RequestParam Long reservedId) {
        reservedService.withdrawReserved(reservedId);
        return new SuccessResponseData();
    }

    @RequestMapping("/renewal")
    public ResponseData renewalReserved(@RequestParam Long reservedId, @RequestParam Long seatId) {
        return new SuccessResponseData(reservedService.renewalReserved(reservedId, seatId));
    }

}
